﻿ using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Web.Http;
using MvcApplication1.Models;

namespace MvcApplication1.Controllers
{
    public class ProductsController : ApiController
    {
        public IEnumerable<ProductModel> GetAllProducts()
        {
            return new List<ProductModel> 
            {
                new ProductModel() { Id = "1", Name = "Gizmo 1", Price = "1.99M" },
                new ProductModel() { Id = "2", Name = "Gizmo 2", Price = "2.99M" },
                new ProductModel() { Id = "34", Name = "Gizmo 3", Price = "3.99M" }
            };
        }

        public ProductModel GetProductById(int id)
        {
            /*
            if (id < 1 || id > 4)
            {
                throw new HttpResponseException(System.Net.HttpStatusCode.NotFound);                
            }*/
            return new ProductModel() { Id = id.ToString(), Name = "Gizmo " + id.ToString(), Price = id.ToString() + 0.99M };
        }
    }
}
